package com.zzyl.nursing.service.impl;

import cn.hutool.core.date.LocalDateTimeUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.nursing.domain.NursingProject;
import com.zzyl.nursing.domain.Orders;
import com.zzyl.nursing.domain.Reservation;
import com.zzyl.nursing.dto.OrdersBody;
import com.zzyl.nursing.mapper.OrdersMemberMapper;
import com.zzyl.nursing.service.OrdersMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class OrdersMemberServiceImpl extends ServiceImpl<OrdersMemberMapper, NursingProject> implements OrdersMemberService {
    @Autowired
    private OrdersMemberMapper omm;

    @Override
    public TableDataInfo<NursingProject> OrdersMemberList(OrdersBody ob) {
//        TableDataInfo<NursingProject> npi = new TableDataInfo<>();
//        Integer total = omm.getTotal(ob);
//        System.out.println("baa:"+total);
//        ob.setPageNum((ob.getPageNum() - 1) * ob.getPageSize());
//        List<NursingProject> rowsa = omm.Rowsa(ob);
//        System.out.println("abb:"+rowsa);
//        npi.setTotal(total);
//        npi.setRows(rowsa);
//        npi.setCode(200);
//        npi.setMsg("查询成功");
//        return npi;
        //创造分页对象
        Page<NursingProject> page=new Page<>(ob.getPageNum(),ob.getPageSize());
        //创建条件构造器
        LambdaQueryWrapper<NursingProject> wrapper=new LambdaQueryWrapper<>();
        String name = ob.getName();
        wrapper.like(name!=null&& !name.isEmpty(),NursingProject::getName,name);
        //用select方法查询NursingProject的全部字段
        Page<NursingProject> resultPage = page(page, wrapper);
        // 将查询结果封装到 TableDataInfo 中
        TableDataInfo<NursingProject> tableDataInfo = new TableDataInfo<>();
        tableDataInfo.setCode(200);
        tableDataInfo.setMsg("查询成功");
        tableDataInfo.setRows(resultPage.getRecords());
        tableDataInfo.setTotal(resultPage.getTotal());
        return tableDataInfo;
    }

}
